#ifndef __I2DFONT_H__
#define __I2DFONT_H__

#include "PowerLibraryEngine.h"

class I2DFont
{
protected:
    stringc FName;
    IImage *img;
    IFont *fnt;
    ITextSceneNode *txtspr;
public:
    I2DFont():img(NULL),fnt(NULL),txtspr(NULL),FName("")
    {
    }

    virtual ~I2DFont()
	{
		Destroy();
	}

	virtual void Destroy()
	{
		DEALLOCATE(img);

		pLogDebug << "Deallocating I2DFont " << FName << "..." << endl;
//		TextureManager->DeleteTexture(txt);
//		DEALLOCATE(spr);
		pLogDebug << "I2DNode " << FName << " deallocated" << endl;

	}

    virtual bool IsLoaded()
    {
        return (img && fnt && txtspr);
    }

    virtual bool LoadNode(stringc FileName)
    {
        FName = FileName;
        img = PLE_FileSystem->GetImage(FName);
        fnt = TextureManager->CreateFontFromImage(img);
		txtspr = SceneManager->GetSceneGenerator()->GetNewTextNode(fnt,"@",ALIGNEMENT_X_RIGHT,ALIGNEMENT_Y_UNDER);
        txtspr->SetName(FileName);
        return IsLoaded();
    }

    virtual bool Copy(I2DFont *Other)
    {
        img = Other->GetImage()->Clone();
//        txt = TextureManager->CreateTextureFromImage(img);
//        spr = SceneManager->GetSceneGenerator()->GetNew2DSpriteSceneNode(txt);
//        spr->SetName(Other->GetSpriteNode()->GetName());
        return IsLoaded();
    }

    virtual bool Clone(I2DNode *Other)
    {
        img = Other->GetImage()->Clone();
//        txt = TextureManager->CloneTexture(Other->GetTexture());
//        spr = SceneManager->GetSceneGenerator()->GetNew2DSpriteSceneNode(txt);
//        spr->SetName(Other->GetSpriteNode()->GetName());
        return IsLoaded();
    }

    virtual ITextSceneNode *GetTextNode()
    {
        return txtspr;
    }

    virtual IImage *GetImage()
    {
        return img;
    }

    virtual stringc GetFName()
    {
        return FName;
    }
};

#endif
